package core;

/**
 * @author Gary
 */
public class GameCharacter extends GameEntity {

    // Character Information
    private short class_id;
    private int experience;
    private int money;
    private int party_id;
    //man-private HashMap<Short, GameItem> equipmentList;
    private boolean online;
    private String save_map_id;
    private float[] save_position;
    // Other Information
    private int battle_id;
    //man-private Vector<GameBattle> battleList;
    //man-private HashMap<Integer, GameInvitation> invitationList;
    private int npc_id;
    private int currentNPCLine;
    private boolean currentNPCSelect;
    private int mode_id;
    private int trade_id;
    private short[] question_ratio;
    private int duel_id;

    public GameCharacter(int char_id) {
        this.object_id = char_id;

        atk_range = 1.0f;
        move_speed = 10.0f;
        scale = 0.4f;

        //man-equipmentList = new HashMap<Short, GameItem>();
        save_position = new float[3];

        base_move_speed = 10.0f;

        battle_id = -1;
       //man- battleList = new Vector<GameBattle>();

        question_ratio = new short[2];

        //man-invitationList = new HashMap<Integer, GameInvitation>();
    }

    public short getClassID() {
        return class_id;
    }

    public short setClassID(short class_id) {
        return this.class_id = class_id;
    }

    public int getExperience() {
        return experience;
    }

    public int setExperience(int experience) {
        return this.experience = experience;
    }

    public int getMoney() {
        return money;
    }

    public int setMoney(int money) {
        if (money < 0) {
            money = 0;
        } else if (money > Constants.MAX_MONEY) {
            money = Constants.MAX_MONEY;
        }

        return this.money = money;
    }

    public int getPartyID() {
        return party_id;
    }

    public int setPartyID(int party_id) {
        return this.party_id = party_id;
    }

    /*man-
    public GameItem getEquipment(short equip_location) {
        return equipmentList.get(equip_location);
    }

    public void setEquipment(GameItem equipment) {
        equipmentList.put(equipment.getEquipLocation(), equipment);
    }

    public HashMap<Short, GameItem> getEquipmentList() {
        return equipmentList;
    }

    public void setEquipmentList(HashMap<Short, GameItem> equipmentList) {
        this.equipmentList = equipmentList;
    }*/

    public boolean getOnline() {
        return online;
    }

    public boolean setOnline(boolean online) {
        return this.online = online;
    }

    public String getSaveMapID() {
        return save_map_id;
    }

    public String setSaveMapID(String save_map_id) {
        return this.save_map_id = save_map_id;
    }

    public float[] getSavePos() {
        return save_position;
    }

    public float[] setSavePos(float[] save_position) {
        return this.save_position = save_position;
    }

    public float getSaveX() {
        return save_position[0];
    }

    public float setSaveX(float x) {
        return save_position[0] = x;
    }

    public float getSaveY() {
        return save_position[1];
    }

    public float setSaveY(float y) {
        return save_position[1] = y;
    }

    public float getSaveZ() {
        return save_position[2];
    }

    public float setSaveZ(float z) {
        return save_position[2] = z;
    }
    /*man-
    public Vector<GameBattle> getBattleList() {
        return battleList;
    }

    public GameBattle getBattle(int battle_id) {
        for (GameBattle battle : battleList) {
            if (battle.getID() == battle_id) {
                return battle;
            }
        }

        return null;
    }

    public void setBattle(GameBattle battle) {
        battleList.add(battle);
    }

    public void removeBattle(int battle_id) {
        for (int i = 0; i < battleList.size(); i++) {
            if (battleList.get(i).getID() == battle_id) {
                battleList.removeElementAt(i);

                if (!battleList.isEmpty()) {
                    if (battle_id == this.battle_id) {
                        if (i < battleList.size()) {
                            this.battle_id = battleList.get(i).getID();
                        } else {
                            this.battle_id = battleList.get(battleList.size() - 1).getID();
                        }
                    }
                } else {
                    this.battle_id = -1;
                }

                break;
            }
        }
    }

    public void clearBattleList() {
        for (GameBattle battle : battleList) {
            battle.removeAttacker(object_id);
        }

        battleList.clear();
        battle_id = -1;
    }

    public GameBattle getCurrentBattle() {
        return getBattle(battle_id);
    }

    public void setCurrentBattle(int battle_id) {
        this.battle_id = battle_id;
    }
    */
    public int getCurrentNPC() {
        return npc_id;
    }

    public int setCurrentNPC(int npc_id) {
        return this.npc_id = npc_id;
    }

    public int getCurrentNPCLine() {
        return currentNPCLine;
    }

    public int setCurrentNPCLine(int index) {
        return currentNPCLine = index;
    }

    public boolean getCurrentNPCSelect() {
        return currentNPCSelect;
    }

    public boolean setCurrentNPCSelect(boolean state) {
        return currentNPCSelect = state;
    }

    public int getGameMode() {
        return mode_id;
    }

    public int setGameMode(int mode_id) {
        return this.mode_id = mode_id;
    }
    /*man-
    public Vector<GameInvitation> getInvitationList() {
        return new Vector<GameInvitation>(invitationList.values());
    }

    public GameInvitation getInvitation(int invitation_id) {
        return invitationList.get(invitation_id);
    }

    public GameInvitation getInvitationByType(short type) {
        for (GameInvitation invitation : invitationList.values()) {
            if (invitation.getType() == type) {
                return invitation;
            }
        }

        return null;
    }

    public GameInvitation setInvitation(GameInvitation invitation) {
        return invitationList.put(invitation.getID(), invitation);
    }

    public GameInvitation removeInvitation(int invitation_id) {
        return invitationList.remove(invitation_id);
    }

    public void clearInvitationList() {
        invitationList.clear();
    }

    public boolean checkEquipment(int inventory_id) {
        for (GameItem item : equipmentList.values()) {
            if (item.getID() == inventory_id) {
                return true;
            }
        }

        return false;
    }

    public GameItem removeEquipment(short equip_location) {
        return equipmentList.remove(equip_location);
    }*/

    public int getTradeID() {
        return trade_id;
    }

    public int setTradeID(int trade_id) {
        return this.trade_id = trade_id;
    }

    public short[] getQuestionRatio() {
        return question_ratio;
    }

    public short[] setQuestionRatio(short[] question_ratio) {
        return this.question_ratio = question_ratio;
    }

    public short getCorrectRatio() {
        return question_ratio[0];
    }

    public short setCorrectRatio(short value) {
        return question_ratio[0] = value;
    }

    public short getWrongRatio() {
        return question_ratio[1];
    }

    public short setWrongRatio(short value) {
        return question_ratio[1] = value;
    }
    /*man-
    public GameDuel getDuel() {
        return duel;
    }

    public GameDuel setDuel(GameDuel duel) {
        return this.duel = duel;
    }

    public void removeDuel() {
        duel = null;
    }*/
}
